<?php
    date_default_timezone_set('PRC');
    //签到
    error_reporting(E_ALL || ~E_NOTICE);
    require_once("ReturnBean.php");
    require_once("WeatherBean.php");
    require_once("mysql.php");
    $date = $_REQUEST["date"];
    $device = $_REQUEST["device"];
    if(!$date||!$device){
        echo json_encode(new ResultBean(501,"参数不全"),JSON_UNESCAPED_UNICODE);
        return;
    }
    $mysqlHelper = new MysqliHelper();
    //mysql查询签到记录
    $res = $mysqlHelper->querySelect("select count(*) num from tbl_sign where sign_date= ? ",$date);
    if($res==0){
        //没有签到 开始签到
        $signRes = $mysqlHelper->insert("insert into tbl_sign(sign_date,createDate,device) values (?,?,?)",$date,date("H:i:sa"),$device);
        if($signRes){
            echo json_encode(new ResultBean(200,"success","执行成功！"),JSON_UNESCAPED_UNICODE);
            return;
        }
        echo json_encode(new ResultBean(401,"insertFail","执行失败！".$signRes),JSON_UNESCAPED_UNICODE);
    }else{
        //已经签过到了
        echo json_encode(new ResultBean(503,"repeatSign","执行失败！重复签到"),JSON_UNESCAPED_UNICODE);
    }
?>